#include"Auto.h"

Mouse::Mouse()
{
	Mouse::pos();
}

void Mouse::pos()
{
	dx = posx();
	dy = posy();
}

int Mouse::posx()
{
	POINT p = { 0,0 };
	GetCursorPos(&p);
	return p.x;
}

int Mouse::posy()
{
	POINT p = { 0,0 };
	GetCursorPos(&p);
	return p.y;
}

void Mouse::move(int x, int y)
{
	sleep(100);
	INPUT inputs[1] = { 0 };
	inputs[0].type = INPUT_MOUSE;
	inputs[0].mi.dx = x;
	inputs[0].mi.dy = y;
	inputs[0].mi.mouseData = 0;
	inputs[0].mi.dwFlags = MOUSEEVENTF_MOVE;
	inputs[0].mi.time = 0;
	UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
}

void Mouse::leftup()
{
	sleep(100);
	INPUT inputs[1] = { 0 };
	inputs[0].type = INPUT_MOUSE;
	inputs[0].mi.dx = 0;
	inputs[0].mi.dy = 0;
	inputs[0].mi.mouseData = 0;
	inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTUP;
	inputs[0].mi.time = 0;
	UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
}
void Mouse::leftdown()
{
	sleep(100);
	INPUT inputs[1] = { 0 };
	inputs[0].type = INPUT_MOUSE;
	inputs[0].mi.dx = 0;
	inputs[0].mi.dy = 0;
	inputs[0].mi.mouseData = 0;
	inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
	inputs[0].mi.time = 0;
	UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
}

void Mouse::rightup()
{
	sleep(100);
	INPUT inputs[1] = { 0 };
	inputs[0].type = INPUT_MOUSE;
	inputs[0].mi.dx = 0;
	inputs[0].mi.dy = 0;
	inputs[0].mi.mouseData = 0;
	inputs[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
	inputs[0].mi.time = 0;
	UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
}
void Mouse::rightdown()
{
	sleep(100);
	INPUT inputs[1] = { 0 };
	inputs[0].type = INPUT_MOUSE;
	inputs[0].mi.dx = 0;
	inputs[0].mi.dy = 0;
	inputs[0].mi.mouseData = 0;
	inputs[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
	inputs[0].mi.time = 0;
	UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
}
void Mouse::rightclick()
{
	Mouse::rightdown();
	Mouse::rightup();
}
void Mouse::leftclick()
{
	Mouse::leftdown();
	Mouse::leftup();
}